// pages/welcome/welcome.js
var app = getApp();

Page({

  data: {
    time: 3
  },

  onLoad: function (options) {
    wx.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: '#ffa739'
    })
    this.getParkData();
    const time = setInterval(() => {
      this.setData({
        time: this.data.time - 1
      });
      if(this.data.time <= 0)
      {
        clearInterval(time)
        wx.redirectTo({
          url: '../index/index',
        })
      } 
    }, 1000)
  },

  getParkData: function (e) {
    var param = [`${app.globalData.park_list[0].parkId}`, `${app.globalData.park_list[1].parkId}`, `${app.globalData.park_list[2].parkId}`];
    const that = this;
    wx.request({
      url: 'https://manager.zjheadway.cn/parking/getExtra?parkId=' + param,
      data: JSON.stringify(param),
      method: 'GET',
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        for (var index = 0; index < app.globalData.park_list.length; index++) {
          app.globalData.park_list[index] = Object.assign(app.globalData.park_list[index], res.data.value[index])
        }
        that.setData({
          dataList: app.globalData.park_list
        });
        app.globalData.onlanch = true;
      }
    })
  }
})